<?php
const DEBUGPRINT=true;
if (DEBUGPRINT) echo  date('Y-m-d [H:i:s]');
if (DEBUGPRINT) echo '<br> index.php';

if (DEBUGPRINT) echo '<br> rec config.php';
require_once 'config.php';


 $name=$_POST['name'];
 $message=$_POST['message'];
 
 if (!isset($_GET['page']))
 	$page = 1;
 else {
    $page=$_GET['page'];
 }

if (DEBUGPRINT) echo '<br> new dal';
$baz = new DAL();


if (DEBUGPRINT) echo '<br> $templates->template_header';
$template = new templates();
$template->template_header();
$template->template_form();


//добавление сообщения

if(@$_GET['add']){
	if (DEBUGPRINT) echo '<br> GET ADD';
  	$baz->addMessage($message, $name);
	if (DEBUGPRINT) echo '<br> GET ADD END';
	header('Location: '.PATH."index.php?page=1");
 }

 
 
	if (DEBUGPRINT) echo '<br> GET ALL';
$template->template_show_message($page);
	if (DEBUGPRINT) echo '<br> GET ALL END';
	
 



//$templates->template_form();
if (DEBUGPRINT) echo '<br> --- index.php';
?>